package com.web;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.entity.ProductBigCategory;
import com.service.ProductBigCategoryService;
import com.service.impl.ProductBigCategoryServiceImpl;

/**
 * Servlet implementation class ProductBigCategoryServlet
 */
@WebServlet("/productBigCategoryServlet")
public class ProductBigCategoryServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ProductBigCategoryServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		String method = request.getParameter("op");
		if(method.equals("queryProductBigSmallCategory")) {
			queryProductBigSmallCategory(request,response);
		}
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

	private void queryProductBigSmallCategory(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		ProductBigCategoryService pbs = new ProductBigCategoryServiceImpl();
		List<ProductBigCategory> listProductBigCategory = pbs.queryProductBigSmallCategory();
		request.setAttribute("listProductBigCategory", listProductBigCategory);
		request.getRequestDispatcher("/manage/product-add.jsp").forward(request, response);
	}
}
